
package com.ukao.steward.pesenter.valetRunners;

import com.ukao.steward.base.BasePresenter;
import com.ukao.steward.bean.BankCardListBena;
import com.ukao.steward.bean.StringBean;
import com.ukao.steward.consts.Constant;
import com.ukao.steward.consts.SaveParams;
import com.ukao.steward.retrofit.ApiCallback;
import com.ukao.steward.util.DecimalUtil;
import com.ukao.steward.util.L;
import com.ukao.steward.view.valetRunners.WithdrawView;

import java.util.HashMap;

/**
 * Created by ukaodev on 2017/6/28.
 */

public class WithdrawPesenter extends BasePresenter<WithdrawView> {


    public WithdrawPesenter(WithdrawView view) {
        attachView(view);
    }





    /**
     我的收入
     */
    public void  bankCardList() {
        mvpView.showLoading();
        HashMap mHashMap = new HashMap<String, String>();
        mHashMap.put("accessToken", SaveParams.getToken());
        addSubscription( apiStores.tradeWalletlist(Constant.createParameter(mHashMap)),
                new ApiCallback<BankCardListBena>() {
                    @Override
                    public void onSuccess(BankCardListBena model) {

                        if (model.getHttpCode() == 200) {
                            mvpView.bankCardListSucceed(model.getData().getList());


                        }else{

                            mvpView.showError(model.getMsg());
                        }

                    }


                    @Override
                    public void onFinish() {

                        mvpView.hideLoading();

                    }
                });

    }


    /**
     我的收入
     */
    public void  tradeAuditapply(final  String  amount, String  walletId) {
        mvpView.showLoading();
        HashMap mHashMap = new HashMap<String, String>();
    final String   stramount=DecimalUtil.multiply(amount);
        mHashMap.put("amount",stramount);/*提现金额*/
        mHashMap.put("walletId", walletId);/*钱包id*/
        mHashMap.put("accessToken", SaveParams.getToken());
        L.i("tradeAuditapply="+mHashMap.toString());
        addSubscription( apiStores.tradeAuditapply(Constant.createParameter(mHashMap)),
                new ApiCallback<StringBean>() {
                    @Override
                    public void onSuccess(StringBean model) {

                        if (model.getHttpCode() == 200) {
                            mvpView.withdrawSucceed(amount,model.getMsg());


                        }else{

                            mvpView.showError(model.getMsg());
                        }

                    }


                    @Override
                    public void onFinish() {

                        mvpView.hideLoading();

                    }
                });

    }


}
